package com.burpee.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.burpee.ui.Addfile;
import com.burpee.ui.Authority;

@Repository(value="authorityDao")
public class AuthorityDaoImpl implements AuthorityDao {

	SqlSessionTemplate sqlSessionTemplate;

	@Autowired
	public void setSqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);
	}

//	public List<Authority> list() {
//
//		List<Authority> list=null;
//
//		try {
//			list = sqlSessionTemplate.selectList("authoritylist");
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//
//		return list;
//	}

	public Authority view(Authority authority) {
		
		Authority authorityview=new Authority();

		try {
			authorityview = sqlSessionTemplate.selectOne("authorityview", authority);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return authorityview;
	}

	public int add(Authority authority) {
		
		int result = 0;

		try {
			result = (int)sqlSessionTemplate.insert("authorityadd",authority);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return result;
	}

	public int modify(Authority authority) {
		
		int result = 0;

		try {
			result = (int)sqlSessionTemplate.update("authoritymodify",authority);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return result;
	}

//	public int remove(Authority authority) {
//		
//		int result = 0;
//
//		try {
//			result = (int)sqlSessionTemplate.update("authorityremove",authority);
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//
//		return result;
//	}

}
